·
<script setup>
import { ref, reactive, watch } from "vue"
const props = defineProps(['visiable', 'choose'])
const emit = defineEmits(['close'])
const acWrap = ref()
const isShow = ref(false)
const form = reactive({
  businessName: '', //商家名
  loginName: '', // 系统账户
  address: "", // 地址
  bank: '', // 开户银行
  bankAccount: '', //银行账户
  bankAccountName: "", // 银行户名
  descript: "", //描述
})
const bankList = ref([
  {
    id: 1,
    bank: '农业银行', // 开户银行
  },
  {
    id: 2,
    bank: '工商银行', // 开户银行
  },
  {
    id: 3,
    bank: '重庆农商行', // 开户银行
  }
])
const close = () => {
  emit('close')
}
watch(() => props.visiable, (val) => {
  if (!val) Object.assign(form, {
    businessName: '', //商家名
    loginName: '', // 系统账户
    address: "", // 地址
    bank: '', // 开户银行
    bankAccount: '', //银行账户
    bankAccountName: "", // 银行户名
    descript: "", //描述
  })
  else {
    Object.assign(form, props.choose)
  }
  isShow.value = val
})
</script>

<template>
  <el-dialog v-model="isShow" title="修改" width="600" @close="close">
    <div class="ac-wrap" ref="acWrap">
      <el-form :model="form" label-width="80px" style="max-width: 600px;margin: 30px auto">

        <el-form-item label="商家名称">
          <el-input v-model="form.businessName" placeholder="名称不超过30个字" />
        </el-form-item>
        <el-form-item label="商家地址">
          <el-input v-model="form.address" placeholder="地址不超过50个字" />
        </el-form-item>
        <el-form-item label="系统账户">
          <el-input v-model="form.loginName" placeholder="输入手机号" />
        </el-form-item>
        <el-form-item label="开户银行">
          <el-select placeholder="请选择" filterable v-model="form.bank">
            <el-option v-for="bl in bankList" :key="bl.id" :label="bl.bank" :value="bl.bank" />
          </el-select>
        </el-form-item>
        <el-form-item label="银行账户">
          <el-input v-model="form.bankAccount" placeholder="输入银行账号" />
        </el-form-item>
        <el-form-item label="银行户名">
          <el-input v-model="form.bankAccountName" placeholder="输入银行户名" />
        </el-form-item>
        <el-form-item label="商家描述">
          <el-input v-model="form.descript" type="textarea" placeholder="不超过100字的描述" />
        </el-form-item>
      </el-form>
    </div>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="isShow = false">取消</el-button>
        <el-button type="primary" @click="isShow = false">
          提交
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<style scoped>
.ac-wrap {
  width: calc(100% - 40px);
  height: calc(100% - 40px);
  position: relative;
  background-color: #fff;
  overflow: auto;
  padding: 0 20px;
}
</style>